#@layout()
#define main()

<div class="layui-container" style="padding-top: 5px;">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md8 content detail">
			<div class="fly-panel data_list">
    		<div class="data_list_title">
    			<i class="layui-icon layui-icon-app"></i>
				<span class="head">帖子信息</span>
    		</div>
	    	<div class="article">
	    		<div class="title">#(article.name??)</div>
		    	<div class="info">
		    		<input type="hidden" name="article.aid" id="imputArticleId" value="#(article.aid??)" />
		    		<a href="" target="_blank">#(article.username)</a>&nbsp;&nbsp;
		    		分享于&nbsp;&nbsp;<font>#date(article.publish_date, "yyyy-MM-dd")</font>
		    		&nbsp;&nbsp;查看次数：&nbsp;<font>#(article.view??) 次</font>
		    		&nbsp;&nbsp;所需：<font color="red">#(article.points??)</font>&nbsp;积分
		    	</div>
		    	<div align="center">
		    		<div class="bshare-custom"><a title="分享到QQ空间" class="bshare-qzone"></a><a title="分享到新浪微博" class="bshare-sinaminiblog"></a><a title="分享到人人网" class="bshare-renren"></a><a title="分享到腾讯微博" class="bshare-qqmb"></a><a title="分享到网易微博" class="bshare-neteasemb"></a><a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a><span class="BSHARE_COUNT bshare-share-count">0</span></div><script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh"></script><script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>
		    	</div>
		    	<div class="downloadBtn">
	    			<button class="layui-btn layui-btn-radius"  onclick="download(#(article.aid))">&nbsp;&nbsp;立即下载&nbsp;&nbsp;</button>
	    			<button class="layui-btn layui-btn-radius" onclick="vipDownload(#(article.aid))" style="background-color: red">&nbsp;&nbsp;VIP免积分下载&nbsp;&nbsp;</button>
	    		</div> 
	    		 
		    	<div id="content" class="content">
		    		<p>#(article.content)</p>
		    	</div>
	    	</div>
    	</div>
    	
    	<!-- 文章评论 -->
    	
		#include("reply.html")
    	
    </div>
    
       <!-- 首页的右边区域 -->
	
		#@left()
	
	</div>	
</div>	

	<!-- 友情链接区域 
	#@link()-->

		
#end

#define js()
<script type="text/javascript" src="/static/jquery.js"></script>
<script type="text/javascript" src="/static/jquery_form/jquery.form.min.js"></script>
<script>
layui.use(['element','laypage','form'], function(){
	  var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
	  var $ = layui.jquery; // 使用jquery
	  var laypage = layui.laypage;
	  
	
});


function submit_btn(aid){
	
	var content=$("#replyContent").val();
	if(content==""){
		layer.msg("请输入评论信息,谢谢您。");
		return;
	}
	
	$.post("/comment/commentUserArticleAdd",{"aid":aid,"content":content},function(result){
		if(result.errMsg == 1){
			layer.alert("您还没有登录，请先去登录。");
			$("#replyContent").text(content);
			return;
		}
		if(result.errMsg == 2){
			history.go(0);
			return;
		}

	});
}


function vipDownload(aid){
	$.post("/article/userVipDownloadExist",{"aid":aid},function(result){
		if(result.errMsg == 1){
			layer.alert("您还没有登录，请先去登录。");
			return;
		}
		
		if(result.errMsg == 2){
			layer.alert("您不是VIP用户，不能通过该方式下载，建议您去充值VIP。");
			return;
		}
		
		if(result.errMsg == 3){
			layer.confirm('尊敬的VIP用户,该资源您已经下载过,您确定要下载这个资源吗？', {
				title:"下载提示"
				  ,btn: ['确定','取消'] //按钮
				}, function(){
					layer.closeAll('dialog');
					layer.open({
					  type: 2,
					  title: '资源下载页面',
					  shadeClose: true,
					  data:'vip',
					  shade: 0.8,
					  area: ['550px', '450'],
					  content: '/article/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
					}); 
				}, function(){
				  
				});
			return;
		}
		if(result.errMsg == 4){
			$.post("/article/userVipDownloadCkeck",{"aid":aid},function(results){
				 if(results.errMsg == 5){
						layer.closeAll('dialog');
						layer.open({
						  type: 2,
						  title: '资源下载页面',
						  shadeClose: true,
						  value:'vip',
						  shade: 0.8,
						  area: ['550px', '450'],
						  content: '/article/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
						}); 
					}else{
						layer.alert("对不起，系统错误，请联系管理员。");
						return;
					}
			});
			return;
		}
	});
}
function download(aid){
	// 判断是否登录，显示默认使用用户已经登录

	// 判断是否下载过
	// 添加记录
	$.post("/article/userDownloadExist",{"aid":aid},function(result){
		if(result.errMsg == 1){
			layer.alert("您还没有登录，请先去登录。");
			return;
		}

		if(result.errMsg == 2){
			layer.confirm('该资您已经下载过,重复下载不会扣除您的积分,您确定要下载这个资源吗？', {
				title:"下载提示"
				  ,btn: ['确定','取消'] //按钮
				}, function(){
					layer.closeAll('dialog');
					layer.open({
					  type: 2,
					  title: '资源下载页面',
					  shadeClose: true,
					  data:'vip',
					  shade: 0.8,
					  area: ['550px', '450'],
					  content: '/article/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
					}); 
				}, function(){
				  
				});
			return;
		}
		
		if(result.errMsg == 4){
			 layer.confirm('该资源下载需要 <font color="red">#(article.points)</font> 积分,您确定要下载这个资源吗？', { 
					title:"下载提示"
						,btn: ['确定','取消'] //按钮
				}, function(){ 
					$.post("/article/userDownloadCkeck",{"aid":aid},function(results){
						if(results.errMsg == 3){
							layer.alert("对不起，您的积分不够，请去充值。");
							return;
						}
						if(results.errMsg == 5){
							layer.closeAll('dialog');
							layer.open({
							  type: 2,
							  title: '资源下载页面',
							  shadeClose: true,
							  value:'vip',
							  shade: 0.8,
							  area: ['550px', '450'],
							  content: '/article/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
							}); 
						}else{
							layer.alert("对不起，系统错误，请联系管理员。");
							return;
						}
					});
				});
			 return;
		}
	});
	
}

</script>

#end